-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make "Experimental" PulseAudio Backend A Viable Option #104
Make "Experimental" PulseAudio Backend A Viable Option #104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
making pulseaudio required is the merge blocker for me.
@@ -52,7 +52,7 @@ void AudioDevice::write(std::shared_ptr<FakeJni::JByteArray> data, FakeJni::JInt | |||
|
|||
void AudioDevice::write2(std::shared_ptr<FakeJni::JShortArray> data, FakeJni::JInt length) { | |||
int error = 0; | |||
if(s && pa_simple_write(s, data->getArray(), length, &error)) { | |||
if(s && pa_simple_write(s, data->getArray(), length * 2, &error)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, you might noticed this is no longer used legacy code as of release 1.0.0.
@@ -22,12 +22,18 @@ else() | |||
endif() | |||
|
|||
if(TARGET SDL3::SDL3) | |||
target_sources(mcpelauncher-client PRIVATE src/jni/sdl3audio.cpp src/jni/sdl3audio.h) | |||
message(VERBOSE "USING SDL3") | |||
target_link_libraries(mcpelauncher-client SDL3::SDL3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link lib is only for audio, e.g. sdl3_audio has it's own SDL_init call for the audio subsystem and is independent from game window.
So it doesn't make sense for me to be enabled if USE_SDL3_AUDIO is off, please join USE_SDL3_AUDIO and TARGET SDL3::SDL3 via and, make if (NOT USE_SDL3_AUDIO)
an else() again. Repeating conditions seems unnecessary to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I see, I thought that TARGET SDL3::SDL3 entailed the whole SDL3 system, not just audio. My mistake. Will improve this!
Are you saying E.g. you make it possible to use sdl3 with pulseaudio audio. |
On NixOS, you can't even use SDL3 for the game window, as it will fail to find the video device (See crash message here). This similar reasoning is why a previous attempt of getting this to work on NixOS had no audio output. I've tried to figure out what might be causing this issue, but I ran into a dead end. It seems like NixOS does not have very good SDL3 support yet, as there is no nixpkg available. As for your example, if I were to follow your comment and merge |
can be improved in a follow up pr |
I noticed that there was an existing implementation of an "experimental" PulseAudio backend. But in every build, this is not used as USE_SDL3_AUDIO is on by default. Well, when trying to build this project for NixOS, the SDL3_AUDIO backend does not work. You will not get an audio output for the reason:
sdl3audio SDL_OpenAudioDeviceStream failed, audio will be unavailable: Audio subsystem is not initialized
NixOS currently does not have an SDL3 package in nixpkgs, and considering that I ditched SDL3 graphics in favor of GLFW, I figured that I should try throwing out SDL3_AUDIO as well.
This pull request actually fixes an issue that is currently present in the PulseAudio backend, where you get crackling audio as a result of many audio underruns. I noticed that the SDL3 backend has a slight difference that wasn't present in the PulseAudio backend. In the method that takes a ShortArray, I noticed that the length is doubled because there's 16 bits in a short as opposed to 8 in a byte. This was not present in the PulseAudio backend. So by simply mirroring this change, that fixed the crackling audio.
mcpelauncher-client/src/jni/sdl3audio.cpp
Lines 42 to 43 in d081dc7
In addition, I made a bit of refactoring to the CMakeLists. Mostly just to take in account of the
USE_SDL3_AUDIO
option, and use the PulseAudio backend whenever it is off. When you turn off that option, and use GLFW as the window system, you can have a set up that does not use SDL at all.This pull request does not enable the PulseAudio backend by default. I'm sure that there is a lot more testing that needs to be done before this could be considered. However, I'm sure this can be considered an alternative option, should things with SDL not work out.